// 爱吃素(数学)
#include <iostream>
#include <cmath>
using namespace std;

using ll = long long;

bool isprime(ll n)
{
    if (n < 2) return false;
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0) return false;
    }
    return true;
}

int main()
{
    ll t, a, b;
    cin >> t;
    while (t--)
    {
        cin >> a >> b;
        if (a == 1 && isprime(b) || b == 1 && isprime(a)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

// 相差不超过k的最多数(滑动窗口)
#include <iostream>
#include <algorithm>
using namespace std;

const int N = 2e5 + 1;
int n, k, res;
int arr[N];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    for (int l = 0, r = 0; r < n; r++)
    {
        while (arr[r] - arr[l] > k)
        {
            l++;
        }
        res = max(res, r - l + 1);
    }
    cout << res << endl;
    return 0;
}

// 最长公共子序列(一)(两个数组的dp)
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int n, m;
string s1, s2;

int main()
{
    cin >> n >> m;
    cin >> s1 >> s2;
    s1 = " " + s1;
    s2 = " " + s2;
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (s1[i] == s2[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}
